<template>
  <div class="infoUploader">
    <van-uploader 
      v-model="uploadList"
      multiple
      :after-read="readAction" 
      :before-delete="deleteAction"
      preview-size="73px"
    />
  </div>
</template>

<script>
import { Uploader } from 'vant';

export default {
  name: "infoUploader",
  components:{
    [Uploader.name]: Uploader,
  },
  props: {
    resultValue: String
  },
  data () {
    return {
      uploadList: []
    }
  },
  methods: {
    readAction(file) {
      this.$api.info.uploadImages(file, (res) => {
        this.$emit('upload-read', 
          {
            resultValue: this.resultValue,
            pathArray: res.data.split(';')
          }
        );
      });
    },
    deleteAction(file, seq) {
      this.$emit('upload-delete', 
        {
          resultValue: this.resultValue,
          index: seq.index
        }
      );
      return true;
    },
  }
};
</script>

<style lang="scss">
.infoUploader{

}
</style>
